
#include "USSegBase.h"


/************************************
 *
 *  Constructor
 *
 ***********************************/
USSegBase 
::USSegBase()
{
	m_CannySeg = new CannySegmentation;
	m_GACSeg = new GACSegmentation;
	m_Segmentation = m_CannySeg;

}



/************************************
 *
 *  Destructor
 *
 ***********************************/
USSegBase 
::~USSegBase()
{

}



 
/************************************
 *
 *  Load Input Image
 *
 ***********************************/
void
USSegBase 
::LoadInputImage( const char * filename )
{
  m_CannySeg->LoadInputImage(filename);
  m_GACSeg->LoadInputImage(filename);
}



/********************************************
 *
 *  Set the seed. From this seed an Initial
 *  level set image is generated 
 *
 *******************************************/
void
USSegBase 
::AddSeed( const IndexType & seedPosition  )
{

  m_CannySeg->AddSeed(seedPosition);
  m_GACSeg->AddSeed(seedPosition);
  
}


  
/************************************
 *
 *  Clear Seeds
 *
 ***********************************/
void
USSegBase 
::ClearSeeds()
{
 
	m_CannySeg->ClearSeeds();
	m_GACSeg->ClearSeeds();

}

 

/********************************************
 *
 *  Set the Sigma value
 *
 *******************************************/
void
USSegBase 
::SetSigma( double value )
{
  m_Segmentation->SetSigma( value );
}



/********************************************
 *
 *  Set the Threshold value for edge strenght
 *
 *******************************************/
void
USSegBase 
::SetThreshold( double value )
{
  ((CannySegmentation*)m_Segmentation)->SetThreshold( value );
}




/************************************
 *
 *  Compute Gradient Magnitude
 *
 ***********************************/
void
USSegBase
::ComputeGradientMagnitude( void )
{
  m_Segmentation->ComputeGradientMagnitude();
}


 
/************************************
 *
 *  Compute Fast Marching
 *
 ***********************************/
void
USSegBase
::ComputeFastMarching( void )
{
  m_Segmentation->ComputeFastMarching();
}


  
/************************************
 *
 *  Compute Zero Set
 *
 ***********************************/
void
USSegBase
::ComputeZeroSet( void )
{
  m_Segmentation->ComputeZeroSet();
}


 



/************************************
 *
 *  Compute Edge Potential Image
 *
 ***********************************/
void
USSegBase
::ComputeEdgePotential( void )
{
  m_Segmentation->ComputeEdgePotential();
}


  

/************************************
 *
 *  Start Segmentation
 *
 ***********************************/
void
USSegBase
::RunCanny( void )
{

  // update the marching filter
  ((CannySegmentation*)m_Segmentation)->RunCanny();

}
void
USSegBase
::RunGeodesicActiveContour( void )
{

 ((GACSegmentation*)m_Segmentation)->RunGeodesicActiveContour();

}





/************************************
 *
 *  Stop Segmentation
 *
 ***********************************/
void
USSegBase
::SetZeroSetValue( InternalPixelType value )
{
 m_Segmentation->SetZeroSetValue(value);
}



/************************************
 *
 *  Stop Segmentation
 *
 ***********************************/
void
USSegBase
::Stop( void )
{
  // TODO: add a Stop() method to Filters

}



void 
USSegBase
::ChangeTabs(Fl_Widget* i)
{
//	cout<<i->label();
	if(i->label() == "Canny")
		m_Segmentation = m_CannySeg;
	else if(i->label() == "Geodesic Active Contours")
		m_Segmentation = m_GACSeg;
}
